package com.esunny.resourcevisualization.controller;

import com.alibaba.fastjson.JSONObject;
import com.esunny.resourcevisualization.proxy.ZentaoSSOProxy;
import com.esunny.resourcevisualization.util.ConstantUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.HashMap;
import java.util.Map;

@Api(value = "测试请求类")
@Controller
//@Deprecated
public class HelloController {
    /**
     * 测试项目是否可用接口
     * @return "hello world"
     */
    @ApiOperation(value = "测试接口")
    @ApiResponse(code = ConstantUtil.HTTP_FAILED_CODE,message = "请求失败",response = String.class)
    @RequestMapping(path = "/hello",method = RequestMethod.GET)
    @ResponseBody
    @CrossOrigin
    public String test(){
        System.out.println("hello");
        return "hello world";
    }

    @RequestMapping("/testSSO")
    @ResponseBody
    public String testSSO(){
        Map<String,String> map = new HashMap<>();
        map.put("username","baochencong");
        map.put("password","ESTest0713");
        JSONObject post = ZentaoSSOProxy.post("/auth/login", map);
        return post.toString();
    }
}
